#ifndef _NINEPATCH_H_LULY_
#define _NINEPATCH_H_LULY_
#include "Image.h"
#include "Rect.h"

//安卓的9patch相比，这个NinePatch是简化版
//伸展区线只支持左边和上边各画一根线（不能画多段）
//内容区线也是各一根（应该和安卓上的一样）

class NinePatch {
  friend class Button;

 private:
  Image image;
  Rect left_top, top, right_top;
  Rect left, center, right;
  Rect left_bottom, bottom, right_bottom;

  int contentWidth, contentHeight;
  int contentToTop, contentToLeft, contentToRight, contentToBottom;

 public:
  NinePatch(Image image);
  //空的9patch
  NinePatch(){};
  void draw(int x, int y, int width, int height);
  void drawArea(Rect area, int x, int y, int width, int height);
  void drawContent(int x, int y, int ContentWidth, int ContentHeight);
  void drawContentArea(Rect area, int x, int y, int ContentWidth,
                       int ContentHeight);
  const int getWidth() { return contentWidth + contentToLeft + contentToRight; }
  const int getHeight() {
    return contentHeight + contentToBottom + contentToTop;
  }
  const int getContentToTop() { return contentToTop; }
  const int getContentToLeft() { return contentToLeft; }
  const int getContentWidth() { return contentWidth; }
  const int getContentHeight() { return contentHeight; }
  const int getContentToRight() { return contentToRight; }
  const int getContentToBottom() { return contentToBottom; }
  const Rect getLeftRect() { return left; }
  const Rect getRightRect() { return right; }
  const Rect getTopRect() { return top; }
  const Rect getBottomRect() { return bottom; }
};

#endif